<template>
    <div>
       <el-dialog title="编辑规格值" :visible.sync="dialogTableVisible" :close-on-click-modal="false">
            <el-form label-width="100px" :model="specValue">
                <el-form-item label="规格值名称">
                    <el-input v-model="specValue.value" autocomplete="off" placeholder=""></el-input>
                </el-form-item>
                <!-- <el-form-item label="id" hidden>
                    <el-input v-model="specValue.specId" autocomplete="off" placeholder=""></el-input>
                </el-form-item> -->
                <el-form-item label="扩展" >
                    <el-input v-model="specValue.extend" autocomplete="off" placeholder=""></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogTableVisible = false">取 消</el-button>
                <el-button type="primary" @click="updatespecs">确 定</el-button>
            </div>
        </el-dialog> 
    </div>
</template>

<script>
import http from '@/utils/request';
export default {
    name: 'ThreeEditSpecValue',

    data() {
        return {
            dialogTableVisible: false,
            specValue: {},
            current: ''
        };
    },

    mounted() {
        //console.log(this.specValue);
    },

    methods: {
        async updatespecs(){
            console.log(this.specValue);
            try {
                // 提交数据
                const r = await http.put('/specValue/update', this.specValue)

                if(r.data.code > 0) {
                    // 给用户一个提示的消息
                    this.$message({
                        message: '数据修改成功',
                        type: 'success'
                    })
                    // 关闭模态框
                    this.dialogTableVisible = false
                    // 数据重新加载
                    this.$emit('refresh',this.current)
                }
            }catch(err) {
                console.log(err)
            }
        }
    },
};
</script>

<style lang="scss" scoped>

</style>